import urllib.request
import random
headers = {
    "User-Agent":"User-Agent, Mozilla/5.0 (Linux; U; Android 2.3.7; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
}
ip_lists = [
    {'http':"114.234.81.105:9000"},
    {'http':"60.13.42.55:9999"},
    {'http':"175.44.156.200:9000"}
]


ua_lists = [
    "User-Agent, Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv,2.0.1) Gecko/20100101 Firefox/4.0.1",
    "User-Agent,Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.8.131 Version/11.11",
    "User-Agent, Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)"
]

proxy = random.choice(ip_lists)
proxy_handler = urllib.request.ProxyHandler(proxies=proxy)

opener = urllib.request.build_opener(proxy_handler)

url = "http://www.ifeng.com/"

req = urllib.request.Request(url,headers=headers)
req.add_header('User-Agent',random.choice(ua_lists))

response = opener.open(req)
print(response)
